from jinja2 import FileSystemLoader, Environment


# 自定义函数
def vendor_filter(vendor):
    new_vendor=vendor[0:3]+['...']
    return new_vendor

vendor_list=['cicso','huawei','h3c','ruijie','fortinet','sangfor']
loader = FileSystemLoader('templates')
env = Environment(loader=loader)
env.filters['vendor_filter']=vendor_filter
tpl=env.get_template('filter.conf.tpl')
output=tpl.render(vendor_list=vendor_list)

print(output)